package com.naizhuai.Model.db.user;

import android.arch.persistence.room.ColumnInfo;
import android.arch.persistence.room.Entity;
import android.arch.persistence.room.Ignore;
import android.support.annotation.NonNull;
import android.text.TextUtils;

import com.google.gson.annotations.SerializedName;
import com.naizhuai.Model.db.Tables;

import java.io.Serializable;

/**
 * 基本用户类
 * Created by code_han on 2018/2/1.
 */
@Entity(tableName = Tables.USER_TABLE,
        primaryKeys = {"uid", "phone"}
)
public class PersonUserBean implements Serializable {
    //用户类的key
    public static final String USER_KEY="user_key";
    //用户id的key
    public static final String USER_ID_KEY="user_id_key";
    //用户名字的key
    public static final String USER_NAME_KEY="user_name_key";
    //用户昵称的key
    public static final String USER_NICK_NAME_KEY="user_nick_name_key";
    //用户头像url的key
    public static final String USER_THUMB_URL_KEY="user_thumb_url_key";
    //用户phone的key
    public static final String USER_PHONE_NUMBER_KEY="user_phone_number_key";
    //用户规定最大疲劳值
    public static final double USER_MAX_FATIGUE_VALUE=10;


    public static final String USER_TASK_SEE_IMAGE="user_task_see_image";
    @NonNull
    @ColumnInfo(name = "uid")
    private String uid;

    @ColumnInfo(name = "truename")
    @SerializedName("truename")
    private String name;

    @SerializedName("sex")
    @ColumnInfo(name = "sex")
    private String sex;
    //用户头像url
    @ColumnInfo(name = "thumb")
    @SerializedName("thumb")
    private String userLogoUrl;

    @ColumnInfo(name = "username")
    @SerializedName("username")
    private String nickName;

    @NonNull
    @ColumnInfo(name = "phone")
    @SerializedName("phone")
    private String phoneNumber;
    @NonNull
    @ColumnInfo(name = "email")
    @SerializedName("email")
    private String email;

    public void setEmail(@NonNull String email) {
        this.email = email;
    }

    @NonNull
    public String getEmail() {
        return email;
    }

    private String passWord;

    @ColumnInfo(name = "powerLevel")
    //所在的公司架构中的权限级别
    private String powerLevel;

    @ColumnInfo(name = "companyId")
    @SerializedName("companyId")
    private String companyId;

    //所在的公司名称
    @ColumnInfo(name = "companyName")
    @SerializedName("companyName")
    private String companyName;

    //所加入的团队名称
    @ColumnInfo(name = "departmentName")
    @SerializedName("departmentName")
    private String departmentName;

    //所在团队的id
    @ColumnInfo(name = "departmentId")
    @SerializedName("departmentId")
    private String departmentId;

    //角色（用于临时创建组的时候信息展示）
    private String departmentRole;

    //是否加入过公司
    @ColumnInfo(name = "isJoinedCompany")
    @SerializedName("isJoinedCompany")
    private String isJoinedCompany;

    @ColumnInfo(name = "departmentPowerCode")
    @SerializedName("departmentPower")
    private String departmentPowerCode;

    @SerializedName("departmentPowerName")
    private String departmentPowerMsg;

    @ColumnInfo(name = "companyPowerCode")
    @SerializedName("companyPower")
    private String companyPowerCode;

    @SerializedName("companyPowerName")
    private String companyPowerMsg;


    /*
    个人疲劳值
    在本季度内，主导任务1分，负责环节0.5分，参与行动0.5分。总分不可超过10分。
    若超过10分，这阶段仅作为提示，即在这个账号在进行添加任务、添加行动和行为揭榜地方给予弹框提示：
    您的负荷值过高，要注意合适安排工作哦。
     */
    private String userFatigue;

    public PersonUserBean() {}

    @Ignore
    public PersonUserBean(String name) {
        this.name = name;
    }

    @Ignore
    public PersonUserBean(String uid, String name, String nickName,String userLogoUrl,String departmentPowerMsg) {
        this.uid = uid;
        this.name = name;
        this.nickName = nickName;
        this.userLogoUrl=userLogoUrl;
        this.departmentPowerMsg=departmentPowerMsg;
    }
    @Ignore
    public PersonUserBean(String uid, String name, String nickName) {
        this.uid = uid;
        this.name = name;
        this.nickName = nickName;
    }
    @Ignore
    public PersonUserBean(@NonNull String uid, String departmentPowerCode) {
        this.uid = uid;
        this.departmentPowerCode = departmentPowerCode;
    }

    public String getUserFatigue() {
        return userFatigue;
    }

    public void setUserFatigue(String userFatigue) {
        this.userFatigue = userFatigue;
    }

    @NonNull
    public String getUid() {
        return uid;
    }

    public void setUid(@NonNull String uid) {
        this.uid = uid;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getSex() {
        return sex;
    }

    public void setSex(String sex) {
        this.sex = sex;
    }

    public String getUserLogoUrl() {
        return userLogoUrl;
    }

    public void setUserLogoUrl(String userLogoUrl) {
        this.userLogoUrl = userLogoUrl;
    }

    public String getNickName() {
        return nickName;
    }

    public void setNickName(String nickName) {
        this.nickName = nickName;
    }

    @NonNull
    public String getPhoneNumber() {
        return phoneNumber;
    }

    public void setPhoneNumber(@NonNull String phoneNumber) {
        this.phoneNumber = phoneNumber;
    }

    public String getPassWord() {
        return passWord;
    }

    public void setPassWord(String passWord) {
        this.passWord = passWord;
    }

    public String getPowerLevel() {
        return powerLevel;
    }

    public void setPowerLevel(String powerLevel) {
        this.powerLevel = powerLevel;
    }

    public String getCompanyId() {
        return companyId;
    }

    public void setCompanyId(String companyId) {
        this.companyId = companyId;
    }

    public String getCompanyName() {
        return companyName;
    }

    public void setCompanyName(String companyName) {
        this.companyName = companyName;
    }

    public String getDepartmentName() {
        return departmentName;
    }

    public void setDepartmentName(String departmentName) {
        this.departmentName = departmentName;
    }

    public String getDepartmentId() {
        return departmentId;
    }

    public void setDepartmentId(String departmentId) {
        this.departmentId = departmentId;
    }

    public String getDepartmentRole() {
        return departmentRole;
    }

    public void setDepartmentRole(String departmentRole) {
        this.departmentRole = departmentRole;
    }

    public String getIsJoinedCompany() {
        return isJoinedCompany;
    }

    public void setIsJoinedCompany(String isJoinedCompany) {
        this.isJoinedCompany = isJoinedCompany;
    }

    public String getDepartmentPowerCode() {
        return departmentPowerCode;
    }

    public void setDepartmentPowerCode(String departmentPowerCode) {
        this.departmentPowerCode = departmentPowerCode;
    }

    public String getDepartmentPowerMsg() {
        return departmentPowerMsg;
    }

    public void setDepartmentPowerMsg(String departmentPowerMsg) {
        this.departmentPowerMsg = departmentPowerMsg;
    }

    public String getCompanyPowerCode() {
        return companyPowerCode;
    }

    public void setCompanyPowerCode(String companyPowerCode) {
        this.companyPowerCode = companyPowerCode;
    }

    public String getCompanyPowerMsg() {
        return companyPowerMsg;
    }

    public void setCompanyPowerMsg(String companyPowerMsg) {
        this.companyPowerMsg = companyPowerMsg;
    }

    public String getPublicPowerMsg(){
        if(!TextUtils.isEmpty(departmentPowerMsg))
            return departmentPowerMsg;
        if(!TextUtils.isEmpty(companyPowerMsg))
            return companyPowerMsg;
        return "";
    }

    public String getShowName(){
        if(!TextUtils.isEmpty(name))
            return name;
        if(!TextUtils.isEmpty(nickName))
            return nickName;
        return "";
    }

    @Override
    public String toString() {
        return getUid();
    }
}
